#ifndef __ST_WEBSOCKET_SERVER_H_H__
#define __ST_WEBSOCKET_SERVER_H_H__
#include <string>
#include "../Util/TypeDef.h"
#include "../Core/TcpServer.h"
#include "../UserDef/StWebsocketSession.h"

class CEventLoop;
class CStWebsocketServer
{
public:
	CStWebsocketServer();
	~CStWebsocketServer();
public:
	void	Init(CEventLoop *loop, const std::string& ip, unsigned short port);
	void	Start();
	void	Stop();
public:
	void	OnNewConnection(net::CTcpConnection *c);
	void	OnConnectionClose(CTcpSession *session);
	void	HandleDailyResCleanUp();
private:
	void	addSession(CStWebsocketSession *s);
	void	delSession(CStWebsocketSession *s);
private:
	net::CTcpServer				*m_server;
	std::vector<CStWebsocketSession*>	m_sessions;
	std::vector<CStWebsocketSession*>  m_needDelSessions;
};

#endif  //!__ST_WEBSOCKET_SERVER_H_H__
